Field of the Invention
The present invention relates to a method and an apparatus for reading out data stored in a storage device, modifying the data and overwriting the data read out with the modified data.
Such methods and apparatus are known and require no further explanation. The storage device may, by way of example, but obviously not exclusively, be registers of devices that can be used as peripheral units of central control units. The central control units are, for example, microprocessors, microcontrollers, signal processors etc. The peripheral units may, for example, be timers, external storage media, and other devices that can be driven by the central control unit. At least some of the registers provided in the peripheral units may be used to frequently change the particular states or operating modes of the peripheral units, or to influence their behavior in some other way. If this is to be done, the content of the relevant register(s) needs to be changed accordingly. To change the register content, it is read out, transferred to the control unit, modified there, then transferred back to the peripheral unit and finally stored in the register (overwriting completely the previous register content) again. Although it is frequently sufficient to change just one or a few bits of the register content in order to achieve the desired effect. For the sake of simplicity (uniformity) the above-mentioned steps usually relate to the entire register content or at least units (words) of the register that include a plurality of bits.
Although such a change to the register content is fast and simple to perform, it is not quite without problems because, after all, not only are those bits of the register content which are to be modified overwritten, but also those bits which are not intended to be modified. Admittedly, it is no trouble at all to overwrite the bits which are not to be modified with the exact values which were read out beforehand, but this does not guarantee that only those bits of the register content which are to be modified are changed. Specifically, if the register content has changed (at the instigation of the peripheral unit itself or of any other devices, for example) between having been read out and having been overwritten, then the bits of the register content which are not to be modified would not be overwritten with the values which they currently hold.
This is naturally a disadvantage that needs to be overcome. One possibility of preventing the above-mentioned effect is for the control unit to inform the peripheral unit (by transmitting a mask, for example) which bits of the register content are affected by the modification performed, and for the peripheral unit then to overwrite only these specific bits in the relevant register. However, transmitting such information involves considerable additional outlay, and is not possible at all in many systems.
It is accordingly an object of the invention to provide a method and apparatus for reading out, modifying and overwriting data stored in a storage device which overcome the above-mentioned disadvantages of the prior art methods and devices of this general type, in which changes to the data stored in the storage device which were made between reading out and overwriting can be reliably prevented from being unintentionally reversed.
With the foregoing and other objects in view there is provided, in accordance with the invention, in an improved method for reading out data stored in a storage device, modifying the data by forming modified data and overwriting the data read out with the modified data, the improvement which includes: comparing the data read out and the modified data with one another before the data read out are overwritten with the modified data, and only those components of the data read out differing from the modified data are overwritten in the storage device.
Accordingly, it is provided that the data read out and the modified data are compared with one another before the data read out are overwritten with the modified data, and only those components of the data read out which differ from the modified data are overwritten. In addition, an overwriting device is provided which is configured to compare the data read out and the modified data with one another before the data read out are overwritten with the modified data, and to overwrite only those components of the data read out which differ from the modified data.
As a result of the comparison between the data read out and the modified data, the unit containing the storage device is able to establish, without any corresponding information from the unit performing the modification, which components of the data have been changed as a result of the modification. Overwriting only those parts of the storage device that have been changed as a result of the modification leaves those parts of the storage device not affected by the modification unchanged. Changes to the data stored in the storage device that are made between reading out and overwriting cannot therefore be reversed unintentionally.
In accordance with an added feature of the invention, there is the step of writing the data read out to a buffer storage device immediately after being read out, and comparing the modified data with the data stored in the buffer storage device during the comparing step.
In accordance with another feature of the invention, there is the step of modifying the data read out by a data modifying device separate from a peripheral unit containing the storage device and an overwriting device for overwriting the data read out.
With the foregoing and other objects in view there is also provided, in accordance with the invention, in combination with a storage device, an apparatus for reading out data stored in the storage device, modifying the data resulting in modified data and overwriting the data read out with the modified data, including: an overwriting device receiving the data read out of the storage device and the modified data for comparing the data read out with the modified data before the data read out are overwritten with the modified data, and to overwrite only those components of the data read out which differ from the modified data.
In accordance with an added feature of the invention, there is a central control unit for modifying the read out data into the modified data, the storage device and the overwriting device forming constituent parts of a peripheral unit controlled by the central control unit.
In accordance with another feature of the invention, the peripheral unit and the central control unit are separate devices.
In accordance with an additional feature of the invention, the central control unit controls the storage device and the overwriting device.
In accordance with a further added feature of the invention, the peripheral device has a buffer storage device receiving the read out data from the storage device and temporarily storing the data read out.
In accordance with a concomitant feature of the invention, the storage device has bit positions for storing the data and the overwriting device overwrites one or more selected bit positions of the storage device. Other features which are considered as characteristic for the invention are set forth in the appended claims.
Although the invention is illustrated and described herein as embodied in a method and apparatus for reading out, modifying and overwriting data stored in a storage device, it is nevertheless not intended to be limited to the details shown, since various modifications and structural changes may be made therein without departing from the spirit of the invention and within the scope and range of equivalents of the claims.
The construction and method of operation of the invention, however, together with additional objects and advantages thereof will be best understood from the following description of specific embodiments when read in connection with the accompanying drawings.